import axios from 'axios';

const API_BASE_URL = 'http://localhost:8080/api/news';

// 创建新闻
export const createNews = (news) => {
    return axios.post(API_BASE_URL, news);
};

// 获取所有新闻
export const getAllNews = () => {
    return axios.get(API_BASE_URL);
};

// 根据ID获取新闻
export const getNewsById = (id) => {
    return axios.get(`${API_BASE_URL}/${id}`);
};

// 更新新闻
export const updateNews = (id, news) => {
    return axios.put(`${API_BASE_URL}/${id}`, news);
};

// 删除新闻
export const deleteNews = (id) => {
    return axios.delete(`${API_BASE_URL}/${id}`);
};